package com.googlecode.jlsf;

import java.net.UnknownHostException;


/**
 * main class
 */
public class Application 
{
	
	public static void main(String[] args) 
	{

		try 
		{	
			IP ip1 = new IP("192.168.177.1", 22);
			IP ip2 = new IP("192.168.177.254", 22);
		
			try 
			{
				Pinger.createIpQueue(ip1, ip2);
			} 
			catch (InterruptedException e) 
			{
				e.printStackTrace();
			}
			
			Pinger.runPingerThreads();
			
			while(true)
			{
				try 
				{
					Thread.sleep(Config.getInstance().getShoutcastTimeout());
				} 
				catch (InterruptedException e) 
				{
					e.printStackTrace();
				}
				
				if(Pinger.getActivePingerThreadsCount() == 0 &&  
						PingerListener.getActiveShoutcastThreadsCount() == 0)
					break;
				
			}
			
			System.out.println("shutdowning all shoutcast threads");
			
			PingerListener.shutdownAllShoutcastThreads();
			
			
		}
		catch (NullPointerException e) 
		{
			e.printStackTrace();
		} 
		catch (UnknownHostException e) 
		{
			e.printStackTrace();
		} 
		catch (IllegalArgumentException e) 
		{
			e.printStackTrace();
		}
	}
	

    
}
